package com.neusoft.dbman.comp.dao.impl;

import java.util.ArrayList;
import java.util.List;

import com.li.core.daoBase.DAOBase;
import com.neusoft.dbman.comp.dao.ProjectuserDao;
import com.neusoft.dbman.comp.model.bean.Projectuser;

public class ProjectuserDaoImpl extends DAOBase implements ProjectuserDao {

	private static String SELECT_SQL = "select databaseid,username,projectid,projectname,psmname,projecttype,usertype,remark from projectuser";
	private static String INSERT_SQL = "insert into projectuser（databaseid,username,projectid,projectname,psmname,projecttype,usertype,remark from projectuser） values(?,?,?,?,?,?,?,?)";

	@Override
	public List<Projectuser> queryProjectUsersByDataBaseId(String databaseId)
			throws Exception {
		List<Projectuser> projectusers = new ArrayList<Projectuser>();
		String[] params = { databaseId };
		String sql = SELECT_SQL + " where databaseid=?";
		return (List<Projectuser>) this.query(sql, params, Projectuser.class);
	}

	@Override
	public List<Projectuser> queryProjectUsersByUserName(String username)
			throws Exception {
		String[] params = { username };
		String sql = SELECT_SQL + " where username=?";
		return (List<Projectuser>) this.query(sql, params, Projectuser.class);
	}

	@Override
	public List<Projectuser> queryProjectUsersByUserName(String databaseId,
			String username) throws Exception {
		String[] params = { databaseId, username };
		String sql = SELECT_SQL + " where databaseId=? and  username=?";
		return (List<Projectuser>) this.query(sql, params, Projectuser.class);
	}

	@Override
	public List<Projectuser> queryProjectUsers(String databaseId,
			String username) throws Exception {
		String[] params = { databaseId, username };
		String sql = SELECT_SQL + " where databaseId=? and  username=?";
		return (List<Projectuser>) this.query(sql, params, Projectuser.class);
	}

	public int insertProjectUser(Projectuser projectuser) throws Exception {
		return this.getJdbcT().update(INSERT_SQL);
	}

}
